package com.pubinfo.passbook.engine.process.variable.medicine;

import com.pubinfo.passbook.common.model.dto.witeoff.MedicineOnJobOrRetireDTO;
import com.pubinfo.passbook.common.model.dubbo.ESBServiceData;
import com.pubinfo.passbook.common.model.ruler.PayInformation;
import com.pubinfo.passbook.common.service.dubbo.DubboService;
import com.pubinfo.passbook.engine.utils.ApplicationContextUilts;

import java.math.BigDecimal;
import java.util.List;

/**
 * @author zhouch
 * @date 2022/4/21 14:45
 */
public class WorkAgeProcessor extends MedicineVariableProcessor {

    DubboService dubboService;

    public WorkAgeProcessor() {
        dubboService = ApplicationContextUilts.getBean(DubboService.class);
    }

    @Override
    public BigDecimal get(MedicineOnJobOrRetireDTO data) {
        List<PayInformation> payInformations = cache.getPayInformationData();
        //报账人的身份证号
        String idNo = payInformations.get(0).getPayerPartyCode();

        ESBServiceData.CertDetail certDetail = dubboService.getPersonsDetailByIdNo(idNo);

        //工龄
        int lengthOfService = Integer.parseInt(certDetail.getWorkTime());

        return new BigDecimal(lengthOfService);
    }
}
